package com.leased.handler;

import com.leased.exception.DatabaseException;
import com.leased.exception.YCException;
import com.leased.request.item.ThatDayItemRequest;
import com.leased.response.ThatDayItemResponse;
import com.leased.service.ItemService;
import com.leased.utils.Page;
import com.leased.utils.YCSystemStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by shencx on 2017/8/3.
 */
@Service
public class ItemHandler {

    Logger LOG = LoggerFactory.getLogger(ItemHandler.class);

    @Resource
    private ItemService itemService;

    /**
     * 获取当天信息列表
     * @param thatDayItemRequest
     * @return
     * @throws YCException
     */
    public Page<ThatDayItemResponse> getThatDayItemPage(ThatDayItemRequest thatDayItemRequest) throws YCException {
        Page<ThatDayItemResponse> page = null;
        try {
            page = itemService.fetchThatDayItemPage(thatDayItemRequest);
            return page;
        }catch (DatabaseException e) {
            LOG.error("getThatDayItemPage exception",thatDayItemRequest);
            throw new YCException(YCSystemStatusEnum.INVOKE_API_RETURN_EXCEPTION.getCode(), YCSystemStatusEnum.INVOKE_API_RETURN_EXCEPTION.getDesc());
        }
    }
}
